#include "StartScreen.h"
#include "NameScreen.h"
#include <MultiWidgets\TextWidget.hpp>
#include <MultiWidgets\ImageWidget.hpp>

void StartScreen::nextScreen(){

	//Radiant::IntrusivePtr<AbstractScreen> temp = MultiWidgets::create<NameScreen>();
	Radiant::BinaryData data;
	//data.write(temp);
	eventSend("nextScreen",data);
	//parentWidget->changeScreen(temp);
}

void StartScreen::init(){

	auto b1 = MultiWidgets::create<MultiWidgets::TextWidget>("name");
	b1->setInputFlags(INPUT_SINGLE_TAPS);
    b1->eventAddListener("single-tap", "nextStart", this);
	addChild(b1);
	setBackgroundColor(0,0,0,1);



	auto logo = MultiWidgets::create<MultiWidgets::ImageWidget>(this);
	logo->load("data/skulllogo.png");
	logo->setSize(height()/2,height()/2);
	logo ->setLocation(width()/3-logo->width()/2,height()/2-logo->height()/2);
	logo->setFixed();

	auto scanner = MultiWidgets::create<MultiWidgets::Widget>(this);
	scanner->setBackgroundColor(1,1,1,1);

	scanner->setSize(height()/2,height()/2);
	scanner ->setLocation(width()/3*2-scanner->width()/2,height()/2-scanner->height()/2);
	scanner->setFixed();

}

 void StartScreen::eventProcess(const QByteArray & messageId, Radiant::BinaryData & data)
  {
    if(messageId == "nextStart") nextScreen();

  }